package com.donfu.system.service.house.impl;

import java.util.Date;
import java.util.List;

import com.donfu.system.domain.house.HouseExclusiveservice;
import com.donfu.system.mapper.house.HouseExclusiveserviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.donfu.system.mapper.house.HouseShoppersMapper;
import com.donfu.system.domain.house.HouseShoppers;
import com.donfu.system.service.house.IHouseShoppersService;

/**
 * 导购信息Service业务层处理
 * 
 * @author donfu
 * @date 2021-12-01
 */
@Service
public class HouseShoppersServiceImpl implements IHouseShoppersService 
{
    @Autowired
    private HouseShoppersMapper houseShoppersMapper;

    @Autowired
    private HouseExclusiveserviceMapper houseExclusiveserviceMapper;

    /**
     * 查询导购信息
     * 
     * @param id 导购信息主键
     * @return 导购信息
     */
    @Override
    public HouseShoppers selectHouseShoppersById(Long id)
    {
        return houseShoppersMapper.selectHouseShoppersById(id);
    }

    /**
     * 查询导购信息列表
     * 
     * @param houseShoppers 导购信息
     * @return 导购信息
     */
    @Override
    public List<HouseShoppers> selectHouseShoppersList(HouseShoppers houseShoppers)
    {
        return houseShoppersMapper.selectHouseShoppersList(houseShoppers);
    }

    /**
     * 新增导购信息
     * 
     * @param houseShoppers 导购信息
     * @return 结果
     */
    @Override
    public int insertHouseShoppers(HouseShoppers houseShoppers)
    {
        houseShoppers.setCreateDate(new Date());
        return houseShoppersMapper.insertHouseShoppers(houseShoppers);
    }

    /**
     * 修改导购信息
     * 
     * @param houseShoppers 导购信息
     * @return 结果
     */
    @Override
    public int updateHouseShoppers(HouseShoppers houseShoppers)
    {
        houseShoppers.setUpdateDate(new Date());
        return houseShoppersMapper.updateHouseShoppers(houseShoppers);
    }

    /**
     * 批量删除导购信息
     * 
     * @param ids 需要删除的导购信息主键
     * @return 结果
     */
    @Override
    public int deleteHouseShoppersByIds(Long[] ids)
    {
        int number=0;
        for(Long id:ids){
            int i = houseShoppersMapper.deleteHouseShoppersById(id);
            // 如果删除导购信息成功，需要删除我的导购的信息
            if(i==1){
                number++;
                houseExclusiveserviceMapper.deleteHouseExclusiveserviceByShopperId(id);
            }
        }
        return number ;
    }

    /**
     * 删除导购信息信息
     * 
     * @param id 导购信息主键
     * @return 结果
     */
    @Override
    public int deleteHouseShoppersById(Long id)
    {
        return houseShoppersMapper.deleteHouseShoppersById(id);
    }

    @Override
    public List<HouseShoppers> selectHouseShoppersListByStoreId(Long id) {
        return houseShoppersMapper.selectHouseShoppersListByStoreId(id);
    }

    /**
     * 含店铺名称
     * @param houseShoppers
     * @return
     */
    @Override
    public List<HouseShoppers> selectHouseShoppersListHaveStoreName(HouseShoppers houseShoppers) {
        return houseShoppersMapper.selectHouseShoppersListHaveStoreName(houseShoppers);
    }
}
